/**
 * 知心云用户详情js
 */

$(function () {
	initialPage();
	getGrid();
});

function initialPage() {
	$(window).resize(function() {
		$('#dataGrid').bootstrapTable('resetView', {height: $(window).height()-56});
	});
}

function getGrid() {
	$('#dataGrid').bootstrapTableEx({
		url: '../../srblive/userDetail/list?_' + $.now(),
		height: $(window).height()-56,
		queryParams: function(params){
			params.keyword = vm.keyword;
			return params;
		},
		columns: [
			{checkbox: true},
			{field : "openid", title : "用户ID", width : "100px"}, 
			{field : "iscertified", title : "资质认证（0否,1是）", width : "100px"}, 
			{field : "isguaranteed", title : "交易担保（0否,1是）", width : "100px"}, 
			{field : "isfefund", title : "不满意退款（0否,1是）", width : "100px"}, 
			{field : "qualification", title : "从业资质", width : "100px"}, 
			{field : "workingyears", title : "从业年限", width : "100px"}, 
			{field : "expertdomain", title : "擅长领域", width : "100px"}, 
			{field : "callprc", title : "语音收费", width : "100px"}, 
			{field : "videoprc", title : "视频收费", width : "100px"}, 
			{field : "interviewprc", title : "面对面收费", width : "100px"}, 
			{field : "advisorytime", title : "个人咨询时长", width : "100px"}, 
			{field : "professionalgrowth", title : "专业成长", width : "100px"}, 
			{field : "therapy", title : "擅长疗法", width : "100px"}, 
			{field : "advisorystyle", title : "咨询风格", width : "100px"}, 
			{field : "training", title : "培训经历", width : "100px"}, 
			{field : "responsetime", title : "响应时长", width : "100px"}, 
			{field : "period", title : "可预约时段", width : "100px"}, 
			{field : "reservationchange", title : "预约变更", width : "100px"}, 
			{field : "belate", title : "爽约迟到", width : "100px"}, 
			{field : "security", title : "知心云保障", width : "100px"}
		]
	})
}

var vm = new Vue({
	el:'#dpLTE',
	data: {
		keyword: null
	},
	methods : {
		load: function() {
			$('#dataGrid').bootstrapTable('refresh');
		},
		save: function() {
			dialogOpen({
				title: '新增知心云用户详情',
				url: 'srblive_html/userDetail/add.html?_' + $.now(),
                width: '80%',
                height: '80%',
				yes : function(iframeId) {
					top.frames[iframeId].vm.acceptClick();
				},
			});
		},
		edit: function() {
			var ck = $('#dataGrid').bootstrapTable('getSelections');
			if(checkedRow(ck)){
				dialogOpen({
					title: '编辑知心云用户详情',
					url: 'srblive_html/userDetail/edit.html?_' + $.now(),
                    width: '80%',
                    height: '80%',
					success: function(iframeId){
						top.frames[iframeId].vm.srbliveUserDetail.id = ck[0].id;
						top.frames[iframeId].vm.setForm();
					},
					yes: function(iframeId){
						top.frames[iframeId].vm.acceptClick();
					}
				});
			}
		},
		remove: function() {
			var ck = $('#dataGrid').bootstrapTable('getSelections'), ids = [];	
			if(checkedArray(ck)){
				$.each(ck, function(idx, item){
					ids[idx] = item.id;
				});
				$.RemoveForm({
					url: '../../srblive/userDetail/remove?_' + $.now(),
			    	param: ids,
			    	success: function(data) {
			    		vm.load();
			    	}
				});
			}
		}
	}
})